package com.java_project.src;
import java.util.Comparator;
public class ProductsSorters {
    public static final Comparator<Product> BY_PRICE_ASC = new Comparator<Product>() {
        @Override
        public int compare(Product p1, Product p2) {
            return Double.compare(p1.getPrice(), p2.getPrice());
        }
    };

    public static final Comparator<Product> BY_PRICE_DESC = (p1, p2) -> Double.compare(p2.getPrice(), p1.getPrice());

    public static final Comparator<Product> BY_STOCK_DESC = Comparator.comparingInt(Product::getStock).reversed();
}